
*------------------------------------------------------------------------------*
* Export main dataset to csv for use in matlab *
*------------------------------------------------------------------------------*


use "data/working/working_platform.dta", clear
sort household_id currency_id
cf _all using "data/working/working_sharepost_Jiarui.dta"

gen aa = 0
replace aa=1 if incomenewdummy==1
drop incomenewdummy
rename aa incomenewdummy

gen aa = 0
replace aa=1 if agenewdummy==1
drop agenewdummy
rename aa agenewdummy

gen aa = 0
replace aa=1 if countrynewdummy==1
drop countrynewdummy
rename aa countrynewdummy

gen aa = 0
replace aa=1 if type_objective==1
drop type_objective
rename aa type_objective

gen aa = 1
replace aa=2 if wave==2
drop wave
rename aa wave

format household_id %20.0f

outsheet using "data/working/Sample.csv", comma  replace  



*------------------------------------------------------------------------------*
* Export main estimates in csv for use in matlab *
*------------------------------------------------------------------------------*


clear all 
est use "output/estimates/table5_col1"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 incomenewdummy	
rename b6 agenewdummy	
rename b7 countrynewdummy	
rename b8 type_objective	
rename b9 log_sp500	
rename b10 log_libor
rename b11 cons

outsheet using "data/working/table5_col1.csv", replace  


clear all 
est use "output/estimates/table5_col2"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 incomenewdummy	
rename b7 agenewdummy	
rename b8 countrynewdummy	
rename b9 type_objective	
rename b10 log_sp500	
rename b11 log_libor
rename b12 cons

outsheet using "data/working/table5_col2.csv", replace  


clear all 
est use "output/estimates/table5_col3"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 incomenewdummy	
rename b8 agenewdummy	
rename b9 countrynewdummy	
rename b10 type_objective	
rename b11 log_sp500	
rename b12 log_libor
rename b13 cons

outsheet using "data/working/table5_col3.csv", replace  



clear all 
est use "output/estimates/table5_col4"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 currencies_potential
rename b8 incomenewdummy	
rename b9 agenewdummy	
rename b10 countrynewdummy	
rename b11 type_objective	
rename b12 log_sp500	
rename b13 log_libor
rename b14 cons

outsheet using "data/working/table5_col4.csv", replace  


*------------------------------------------------------------------------------*
* Export heterogeneity estimates in csv for use in matlab *
*------------------------------------------------------------------------------*


clear all 
est use "output/estimates/table6_col1"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 currencies_potential
rename b8 incomenewdummy	
rename b9 agenewdummy	
rename b10 countrynewdummy	
rename b11 type_objective	
rename b12 log_sp500	
rename b13 log_libor
rename b14 cons

outsheet using "data/working/table6_col1.csv", replace  


clear all 
est use "output/estimates/table6_col2"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 currencies_potential
rename b8 incomenewdummy	
rename b9 agenewdummy	
rename b10 countrynewdummy	
rename b11 type_objective	
rename b12 log_sp500	
rename b13 log_libor
rename b14 cons

outsheet using "data/working/table6_col2.csv", replace  



clear all 
est use "output/estimates/table6_col3"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 currencies_potential
rename b8 incomenewdummy	
rename b9 agenewdummy	
rename b10 countrynewdummy	
rename b11 type_objective	
rename b12 log_sp500	
rename b13 log_libor
rename b14 cons

outsheet using "data/working/table6_col3.csv", replace  


clear all 
est use "output/estimates/table6_col4"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 currencies_potential
rename b8 incomenewdummy	
rename b9 agenewdummy	
rename b10 countrynewdummy	
rename b11 type_objective	
rename b12 log_sp500	
rename b13 log_libor
rename b14 cons

outsheet using "data/working/table6_col4.csv", replace  


 
clear all 
est use "output/estimates/table6_col5"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 currencies_potential
rename b8 incomenewdummy	
rename b9 agenewdummy	
rename b10 countrynewdummy	
rename b11 type_objective	
rename b12 log_sp500	
rename b13 log_libor
rename b14 cons

outsheet using "data/working/table6_col5.csv", replace  


clear all 
est use "output/estimates/table6_col6"
ereturn disp
matrix b = get(_b)
matrix list b 
svmat double b 

rename b1 logME 	
rename b2 beta	
rename b3 momentum4	
rename b4 pow	
rename b5 short_increase	
rename b6 long_decrease	
rename b7 currencies_potential
rename b8 incomenewdummy	
rename b9 agenewdummy	
rename b10 countrynewdummy	
rename b11 type_objective	
rename b12 log_sp500	
rename b13 log_libor
rename b14 cons

outsheet using "data/working/table6_col6.csv", replace  
